package br.edu.cesar.aula09;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import br.edu.cesar.aula09.GoogleNewsListFragment.Noticia;

import com.squareup.picasso.Picasso;

public class GoogleNewsAdapter extends ArrayAdapter<Noticia> {

	public GoogleNewsAdapter(Context context, List<Noticia> objects) {
		super(context, 0, objects);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Noticia youtubeVideo = getItem(position);
		
		if (convertView == null){
			convertView = LayoutInflater.from(getContext()).
					inflate(R.layout.layout_linha_video, null);
		}
		
//		ImageView imgThumbnail = (ImageView)
//				convertView.findViewById(R.id.imgThumbnail);
		TextView txtTitulo = (TextView)
				convertView.findViewById(R.id.txtTitulo);
		TextView txtAutor = (TextView)
				convertView.findViewById(R.id.txtAutor);
		
//		Picasso.with(getContext()).load(youtubeVideo.thumbnail).into(imgThumbnail);
		txtTitulo.setText(youtubeVideo.titulo);
		txtAutor.setText(youtubeVideo.link);
		
		return convertView;
	}
}
